package com.yuyou.tas.lesson.api;

import com.yuyou.tas.lesson.mapper.LessonClassStudentMapper;
import com.yuyou.tas.lesson.service.ILessonClassService;
import com.yuyou.tas.lesson.service.ILessonClassUserRelService;
import com.yuyou.tas.service.api.feedback.vo.resp.FeedbackClassesVo;
import com.yuyou.tas.service.api.lesson.dto.LessonClassDTO;
import com.yuyou.tas.service.api.lesson.dto.LessonClassPage;
import com.yuyou.tas.service.api.lesson.dto.LessonClassPageDTO;
import com.yuyou.tas.service.api.lesson.dto.LessonClassSyncDTO;
import com.yuyou.tas.service.api.lesson.entity.LessonClass;
import com.yuyou.tas.service.api.lesson.entity.LessonClassUserRel;
import com.yuyou.tas.service.api.lesson.service.LessonClassAPI;
import com.yuyou.tas.util.bean.Pagination;
import com.yuyou.tas.util.bean.ResBoolSimpleInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class LessonClassAPIImpl implements LessonClassAPI{

	@Autowired
	private ILessonClassService lessonClassService;
	
	@Autowired
	private ILessonClassUserRelService lessonClassUserRelService;

	@Autowired
	private LessonClassStudentMapper lessonClassStudentMapper;

	@Override
	public ResBoolSimpleInfo<String> sycnClasssByOId(@RequestBody List<LessonClassSyncDTO> list)
			throws Exception {
		return lessonClassService.sycnClassByOId(list);
	}

	@Override
	public ResBoolSimpleInfo<String> delByOrgan7OIds(@RequestParam("oIds") List<Long> oIds,
			@RequestParam("authOrganizationId") Long authOrganizationId) throws Exception {
		return lessonClassService.delByOrgan7OIds(oIds, authOrganizationId);
	}

	@Override
	public List<LessonClassUserRel> findByUserId(@RequestParam("userId") Long userId) {
		return lessonClassUserRelService.findByUserId(userId);
	}

	@Override
	public LessonClass findLessonClassByClassId(Long classId) {
		return lessonClassService.selectByPrimaryKey(classId);
	}

	@Override
	public LessonClassDTO findLessonClassDTOByClassId(Long classId) {
		return lessonClassService.findLessonClassByClassId(classId);
	}

	@Override
	public List<LessonClass> findLessonClassByClassIds(@RequestParam("lessonClassIds") List<Long> lessonClassIdList) {
		List<LessonClass> lessonClassList = lessonClassService.findLessonClassByClassIds(lessonClassIdList);

		return lessonClassList;
	}

	@Override
	public ResBoolSimpleInfo<String> updateLessonClassStatus() {
		lessonClassService.updateLessonClassStatus();

		return new ResBoolSimpleInfo<>(true, null);
	}

	@Override
	public LessonClass selectById(@RequestParam("id") Long id) {
		return lessonClassService.selectByPrimaryKey(id);
	}

	@Override
	public int findLessonClassPageCount(@RequestBody Pagination<LessonClassPageDTO> p){
		return lessonClassService.findLessonClassPageCount(p);
	}

	@Override
	public List<LessonClassPageDTO> findLessonClassPageList(@RequestBody Pagination<LessonClassPageDTO> p) {
		List<LessonClassPageDTO> lessonClassPageList = lessonClassService.findLessonClassPageList(p);
		return lessonClassPageList;
	}

	@Override
	public Integer getStudentCountByClassId(Long classId) {
		return lessonClassStudentMapper.getStudentCountByClassId(classId);
	}

	@Override
	public ResBoolSimpleInfo<LessonClassPage> findLessonClassByTeacher(Long teacherId, Long schoolId, Long trimesterId, Long sectionId, Long levelId, Integer pageSize, Integer pageIndex) {
		return lessonClassService.findLessonClassByTeacher(teacherId , schoolId , trimesterId ,sectionId , levelId ,pageSize ,pageIndex);
	}

	@Override
	public ResBoolSimpleInfo<List<FeedbackClassesVo>> findFeedbackLessonClassByTeacher(Long teacherId, Long trimesterId) {
		return lessonClassService.findFeedbackLessonClassByTeacher(teacherId , trimesterId);
	}

	@Override
	public List<LessonClass> findByClassIdsAndClassStatus(@RequestParam("classIds")List<Long> classIds, @RequestParam("classStatus")Integer classStatus) {
		return lessonClassService.findByClassIdsAndClassStatus(classIds, classStatus);
	}

}
